package com.yoomiito.app.adapter.my;

import androidx.annotation.Nullable;

import android.util.TypedValue;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yoomiito.app.R;
import com.yoomiito.app.model.my.MyHistoryIncomeBean;
import com.yoomiito.app.utils.ResUtil;
import com.yoomiito.app.utils.SpannableUtils;

import java.util.List;

public class MyHistoryIncomeAdapter extends BaseQuickAdapter<MyHistoryIncomeBean, BaseViewHolder> {
    public MyHistoryIncomeAdapter(@Nullable List<MyHistoryIncomeBean> data) {
        super(R.layout.item_my_history_income, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, MyHistoryIncomeBean item) {
        helper.setVisible(R.id.otherDesTv,true);
        helper.setVisible(R.id.iv_arrow, true);
        TextView date = helper.getView(R.id.tv_date);
        TextView taobaoGoodsTv = helper.getView(R.id.tv_taobao);
        TextView ownGoodsTv =helper.getView(R.id.tv_gift_explosive);
        TextView other = helper.getView(R.id.otherDesTv);
        if (item.isTitle()){
            date.setText(item.getYear() + "年");
            taobaoGoodsTv.setText("导购引流");
            ownGoodsTv.setText("自营商品");
            other.setText("其他");

            taobaoGoodsTv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,14);
            ownGoodsTv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,14);
            other.setTextSize(TypedValue.COMPLEX_UNIT_DIP,14);

            date.setTextColor(ResUtil.getColor(R.color.color_balk_999999));
            taobaoGoodsTv.setTextColor(ResUtil.getColor(R.color.color_balk_999999));
            ownGoodsTv.setTextColor(ResUtil.getColor(R.color.color_balk_999999));
            other.setTextColor(ResUtil.getColor(R.color.color_balk_999999));

            helper.setVisible(R.id.iv_arrow, false);
//            helper.addOnClickListener(-1);
        }else{
            date.setText(item.getMonth() + "月");
            taobaoGoodsTv.setText(""+item.getTt1());
            taobaoGoodsTv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,12);
            ownGoodsTv.setText(""+item.getTt2());
            ownGoodsTv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,12);
            other.setText(SpannableUtils.saleNum2(item.getOthers()));
            other.setTextSize(TypedValue.COMPLEX_UNIT_DIP,12);

            date.setTextColor(ResUtil.getColor(R.color.color_balk_333333));
            taobaoGoodsTv.setTextColor(ResUtil.getColor(R.color.color_balk_333333));
            ownGoodsTv.setTextColor(ResUtil.getColor(R.color.color_balk_333333));
            other.setTextColor(ResUtil.getColor(R.color.color_balk_333333));

            helper.setVisible(R.id.iv_arrow, true);
//            helper.addOnClickListener(R.id.item_my_history_income);
        }
    }
}
